<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <form method="post" enctype="multipart/form-data" class="form">
        <div class="form-group">
            <label>标题</label>
            <input type="text" name="title" class="form-control" placeholder="请输入文章标题">
        </div>
        <div class="form-group">
            <label>作者</label>
            <input value="test" type="text" class="form-control" readonly>
            <input type="hidden" name="author" value="626c199780674bf5ea0175b9" id="">
        </div>
        <div class="form-group">
            <label>发布时间</label>
            <input type="date" name="publish_time" class="form-control">
        </div>
        
        <div class="form-group">
           <label for="exampleInputFile">文章封面</label>
           <input name="mask_img" type="file" placeholder="可进行多选">
           <div class="thumbnail-waper">
               <!-- <img class="img-thumbnail" src="http://tmp/UkAdU7z527QD5e515fd5996c71bf20ca23d006ea5b98.jpg"> -->
           </div>
        </div>
        <div class="form-group">
            <label>内容</label>
            <textarea name="content" class="form-control" id="editor"></textarea>
        </div>
        <div class="buttons">
            <input type="button" class="btn btn-primary">
        </div>
    </form>
</body>
</html>

<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
<script>
    $(function(){
            $("[name=mask_img]").change(function(e){
                let file=e.target.files[0];
                // let files=e.target.files;
                console.log(file);
                // let imgs=``;
                for(let i=0;i<files.length;i++){
                    let fileReader=new FileReader();
                    fileReader.onloadend=function(e){
                        let imageData=e.target.result;
                        let imgs=`
                        <img class="img-thumbnail" src="${imageData}">
                        `;
                        $(".thumbnail-waper").append(imgs);
                    }
                    fileReader.readAsDataURL(files[i]);
                };
                // $(".thumbnail-waper").append(imgs);
                // let fileReader=new FileReader();
                // fileReader.onloadend=function(e){
                //     console.log(e);
                //     let imageData=e.target.result;
                //     $(".img-thumbnail").attr("src",imageData)
                // }
                // fileReader.readAsDataURL(files);
            });
            $(".btn-primary").on("click",function(e){
                console.log($(".form"));
            })
        })
</script>